#include <stdio.h>

typedef unsigned char DataType;

#define MAX_ADDRESS 0xFFFF
#define BEGIN_NUMBER 0
#define END_NUMBER 31

DataType MEMD[MAX_ADDRESS+1];


void saveMEMD(char *file){        //zapisz zawarto�� pami�ci danych do pliku
    FILE *file_ptr;
    file_ptr=fopen(file, "wb");
    if(!file_ptr){
        printf("MEMD cannot open to write (%s)!\n", file);
        exit(1);
    }
    fseek(file_ptr, 0, SEEK_SET);
    fwrite(MEMD, MAX_ADDRESS+1, 1, file_ptr);
    fclose(file_ptr);
}

void loadMEMD(char *file){        //�adowanie pami�ci danych z pliku
     FILE *file_ptr;
    file_ptr=fopen(file, "rb");
    if(!file_ptr){
        printf("MEMD file not found (%s)!\n", file);
        exit(2);
    }
    fseek(file_ptr, 0, SEEK_SET);
    fread(MEMD, MAX_ADDRESS+1, 1, file_ptr);
    fclose(file_ptr);
}

int main(){
  loadMEMD("file_data.bin");
  int i = 0;
  
  for(i = BEGIN_NUMBER; i < END_NUMBER; i++)
    printf("%d\n",MEMD[i]);
  
  
  return 0;
}
  
  
